package com.zhuiyun.project.security.commonhandler;

import org.springframework.security.authentication.AuthenticationServiceException;

import javax.servlet.http.HttpServletRequest;


/**
 * @ClassName RequestMethodVerification
 * @Description 针对request 中的请求方式限制校验
 * @Author zcy
 * @Date 2023/4/7 10:49
 **/
public class RequestMethodVerification {

    /**
     * 验证post
     * @param request
     */
    public static void postVerification(HttpServletRequest request){
        String method = request.getMethod();
        // 仅使用POST方法提交
        if(!"POST".equalsIgnoreCase(method)){
            throw new AuthenticationServiceException(
                    "Authentication method not supported: " + request.getMethod());
        }
    }
}
